import { stringify } from 'qs';
import request from '@/utils/request';
import { getPageSize } from '@/utils/common';

export async function selectList(params) {
  params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/tms/tms-driver/selectList`, {
    method: 'POST',
    body: params,
  });
}
export async function selectDetails(params) {
  return request(`/server/api/tms/tms-driver/viewDetails`, {
    method: 'POST',
    body: params,
  });
}
export async function selectPapersDetails(params) {
  return request(`/server/api/tms/tms-driver-papers/viewPapersDetails`, {
    method: 'POST',
    body: params,
  });
}
/**
 * 新增编辑司机
 */
export async function driverOperate(params) {
  const url = params.id ? 'tms-driver/updateDriver' : 'tms-driver/insertDriver';
  return request(
    `/server/api/tms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}
/**
 * 新增编辑证件
 */
export async function paperOperate(params) {
  const url = params.id ? 'tms-driver-papers/updatePapers' : 'tms-driver-papers/insertPapers';
  return request(
    `/server/api/tms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}
export async function selectDictByCode(params) {
  return request(`/server/api/tms/tms-dictionary/selectDictByCode`, {
    method: 'POST',
    body: params,
  });
}
//启用禁用
export async function ableDriverOperate(params) {
  const url = params.type ? 'tms-driver/enableDriver' : 'tms-driver/disabledDriver';
  return request(
    `/server/api/tms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}
